{layout name="main"/}
<div class="wrapper wrapper-content animated fadeInUp">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">

                <div class="input-group">

                    <input type="text" placeholder="请使用会员编号或昵称进行搜索" name="keyword" class="form-control input-lg">
                    <div class="input-group-btn">
                        <button class="btn btn-lg btn-primary" type="button" onclick="search()">
                            搜索
                        </button>
                    </div>
                </div>
            </div>
        </div>


        <div class="col-sm-3">
            <div class="ibox">
                <div class="ibox-content">
                    <div class="widget style1">
                        <div class="row">
                            <div class="col-xs-4 text-center">
                                <i class="fa fa-user-plus fa-5x"></i>
                            </div>
                            <div class="col-xs-8 text-right">
                                <span> 直推人数 </span>
                                <h2 class="font-bold"> {$user->son_users()->count()}</h2>
                            </div>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="widget style1">
                        <div class="row">
                            <div class="col-xs-4 text-center">
                                <i class="fa fa-users fa-5x"></i>
                            </div>
                            <div class="col-xs-8 text-right">
                                <span> 团队人数 </span>
                                <h2 class="font-bold"> {$user->all_son_users()->count()}</h2>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-9">
            <div class="ibox">
                <div class="ibox-content">
                    <div class="alert alert-warning">

                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>
                          图例注解： 所在层数[*] 用户账号[******] 昵称[******] 会员类型[*****] 会员等级[******] 直推人数[******]</span>
                    </div>


                    <div id="jstree1">

                    </div>
                </div>
            </div>
        </div>

    </div>
</div>


<script>
    $(document).ready(function() {
        $("#jstree1").jstree({
            "core": {
                'data': {
                    "url": "{:url('admin/User/getUserRecommendUserJson',['father'=>$father])}",
                    "data": function(node) {
                        return {
                            "id": node.id
                        };
                    },
                },
            },
            "plugins": ["types"],
            'types': {
                "default": {
                    "icon": "fa fa-user"
                },
            },
            //                     "html":{"icon":"fa fa-file-code-o"},
            //                     "svg":{"icon":"fa fa-file-picture-o"},
            //                     "css":{"icon":"fa fa-file-code-o"},
            //                     "img":{"icon":"fa fa-file-image-o"},
            //                     "js":{"icon":"fa fa-file-text-o"}



        });
    });
    function search() {
        var url = "{:url('admin/User/findSonUserJson',[],'')}";
        var keyword = $("input[name=keyword]").val();
        if (keyword != "") {
            url = url + "/keyword/" + keyword;
        }
        post({
            url: url,
            success: function (res) {
              url="{:url('admin/User/getMyRecommendTree',[],'')}"+"/father/"+res.message;
              toUrl(url);
            },
            error: function (error) {
                swal("错误", JSON.parse(error.responseText).message, "error");
            }
        });
    }

</script>
